#include "KeyLineEdit.h"
#include <QDebug>
#include <QKeyEvent>

KeyLineEdit::KeyLineEdit(QWidget *parent)
    : QLineEdit(parent)
{

}

/*
    QEvent 所有事件的基类
*/
void KeyLineEdit::keyPressEvent(QKeyEvent *e)
{
    if(e->key() == Qt::Key_Return
            && e->modifiers() == Qt::ControlModifier){
        emit sigTextChanged(this->text());
    }else{
        QLineEdit::keyPressEvent(e);
    }



    //键盘事件是默认忽略的.
    /*
    用于组合按键
    Qt::KeyboardModifiers modifiers() const

    */
    /*
    if(e->key() == Qt::Key_Z
            && e->modifiers() == Qt::AltModifier){
        this->hide();
        qDebug() << "按下了大写Z键...";
    }else{
        //调用默认实现
        QLineEdit::keyPressEvent(e);
    }
    */
}
